//
//  DMAppointmentController.m
//  MCNKuaiYi
//
//  Created by ling on 17/1/8.
//  Copyright © 2017年 Mr.Cannon. All rights reserved.
// 51bd95

#import "DMAppointmentController.h"
#import "DoctorCountView.h"
#import "DMPathemaDetailController.h"
#import "DMSyndromeController.h"
#import "DMApplyAppointmentController.h"
#import "DMDiseaseHistoryController.h"

@interface DMAppointmentController ()

//确诊按钮
@property(nonatomic,strong)UIButton *tureButton;
//曾经治疗方式
@property(nonatomic,strong)UIView *isTreatmentView;
//推荐医生数量
@property(nonatomic,strong)UIView *doctorCountView;

//疾病类型lab
@property(nonatomic,strong)UILabel *label;

@end

@implementation DMAppointmentController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.view.backgroundColor = [UIColor cz_colorWithRed:239 green:239 blue:243];
    
    [self setupUI];
    
//    NSLog(@"----%ld",(long)_id);

//    self.navigationItem.title = @"肿瘤";
    switch (_id)
    {
        case 1:
            self.navigationItem.title = @"肿瘤";
            _label.text = @"疾病类型:肿瘤";
            break;
        case 2:
            self.navigationItem.title = @"心血管";
            _label.text = @"疾病类型:心血管";
            break;
        case 3:
            self.navigationItem.title = @"神经科";
            _label.text = @"疾病类型:神经科";
            break;
        case 4:
            self.navigationItem.title = @"血液科";
            _label.text = @"疾病类型:血液科";
            break;
        case 5:
            self.navigationItem.title = @"骨科";
            _label.text = @"疾病类型:骨科";
            break;

    }
  
}


#pragma mark - 手势监听
//MARK: 选择疾病手势
- (void)selectDiseaseTpa:(UIGestureRecognizer *)sender
{
    DMPathemaDetailController *pathemaDetailC = [[DMPathemaDetailController alloc]init];
    
    pathemaDetailC.id = _id;
    
    [self.navigationController pushViewController:pathemaDetailC animated:YES];
}

//MARK: 并发症选择手势
- (void)syndromeTap:(UIGestureRecognizer *)sender
{
    DMSyndromeController *syndromeC = [[DMSyndromeController alloc]init];
    
    [self.navigationController pushViewController:syndromeC animated:YES];

}

//MARK: 申请预约点击手势
- (void)tapChilk
{
    DMApplyAppointmentController *applyAppointC = [[DMApplyAppointmentController alloc]init];
    
    [self.navigationController pushViewController:applyAppointC animated:YES];
}

//MARK: 曾经治疗方式点击手势
- (void)istreatmentTap:(UIGestureRecognizer *)sender
{
    DMDiseaseHistoryController *diseaseHistoryC = [[DMDiseaseHistoryController alloc]init];
    
    [self.navigationController pushViewController:diseaseHistoryC animated:YES];
}



#pragma mark - 按钮事件监听
//MARK: 确诊按钮事件
- (void)tureBtnChilk:(UIButton *)sender
{

}

//MARK: 有治疗史按钮事件
- (void)yesBtn:(UIButton *)sender
{
    _isTreatmentView.hidden = NO;
    _doctorCountView.hidden = NO;
    _bottonView.backgroundColor = [UIColor cz_colorWithHex:0x40E0D0];
    _bottonView.userInteractionEnabled = YES;
}

//MARK: 没有治疗史按钮
- (void)noBtn:(UIButton *)sender
{
    _isTreatmentView.hidden = YES;
    _doctorCountView.hidden = NO;
    _bottonView.backgroundColor = [UIColor cz_colorWithHex:0x40E0D0];
    _bottonView.userInteractionEnabled = YES;
}


#pragma mark - 搭建界面
- (void)setupUI
{
    //MARK:预约按钮视图
    UIView *bottonView = [[UIView alloc]init];
//    bottonView.backgroundColor = [UIColor cz_colorWithHex:0x40E0D0];
    bottonView.backgroundColor = [UIColor cz_colorWithHex:0x6d6d6d];
    
    bottonView.userInteractionEnabled = NO;
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapChilk)];
    
    [bottonView addGestureRecognizer:tap];
    [self.view addSubview:bottonView];
    
    [bottonView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(250, 40));
        make.centerX.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(-20);
        
    }];
    
    //预约文字
    UILabel *label = [UILabel cz_labelWithText:@"申请预约" fontSize:18 color:
                      [UIColor whiteColor]];
    
    [bottonView addSubview:label];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.center.equalTo(bottonView);
        
    }];
    
    //MARK: 医生数量
    DoctorCountView *doctorCountV = [DoctorCountView doctorCount];
    
    doctorCountV.hidden = YES;
    
    [self.view addSubview:doctorCountV];
    
    [doctorCountV mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(bottonView.mas_top).offset(-10);
        
    }];
    
    
    UIView *view = [[UIView alloc]init];
//    view.backgroundColor = [[UIColor cz_colorWithRed:239 green:239 blue:243];
    view.backgroundColor = [UIColor cz_colorWithRed:239 green:239 blue:243];
    
    [self.view addSubview:view];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.right.equalTo(self.view);
        make.height.mas_equalTo(1);
        
    }];
    
    

    //MARK:疾病类型视图
    UIView *diseaseView = [[UIView alloc]init];
    diseaseView.backgroundColor = [UIColor cz_colorWithRed:239 green:239 blue:243];
    
    diseaseView.layer.cornerRadius = 10;
    diseaseView.layer.masksToBounds = YES;
    
    [self.view addSubview:diseaseView];
    
    [diseaseView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(view.mas_bottom).offset(3);
        make.left.right.equalTo(self.view);
//        make.left.equalTo(self.view).offset(15);
//        make.right.equalTo(self.view).offset(-15);
        make.height.mas_equalTo(50);
        
    }];
    
    UILabel *lab = [UILabel cz_labelWithText:@"疾病类型:" fontSize:20 color:[UIColor cz_colorWithHex:0x6d6d6d]];
    
    [diseaseView addSubview:lab];
    
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(diseaseView).offset(25);
        make.centerY.equalTo(diseaseView);
        
    }];
    
    
    //MARK:疾病选择视图
    UIView *selectDisease = [[UIView alloc]init];
    selectDisease.backgroundColor = [UIColor whiteColor];
    
    selectDisease.layer.cornerRadius = 10;
    selectDisease.layer.masksToBounds = YES;
    
    UITapGestureRecognizer *selectDiseaseTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(selectDiseaseTpa:)];
    
    [selectDisease addGestureRecognizer:selectDiseaseTap];
    [self.view addSubview:selectDisease];
    
    [selectDisease mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(diseaseView.mas_bottom).offset(5);
        make.left.equalTo(self.view).offset(15);
        make.right.equalTo(self.view).offset(-15);
        make.height.mas_equalTo(40);
        
    }];

    UILabel *selectLab = [UILabel cz_labelWithText:@"请选择疾病类型:" fontSize:18 color:[UIColor cz_colorWithHex:0x40E0D0]];
    
    [selectDisease addSubview:selectLab];
    
    [selectLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(selectDisease).offset(5);
        make.centerY.equalTo(selectDisease);
        
    }];
    
    //MARK: 并发症视图
    UIView *syndromeView = [[UIView alloc]init];
    syndromeView.backgroundColor = [UIColor whiteColor];
    
    syndromeView.layer.cornerRadius = 10;
    syndromeView.layer.masksToBounds = YES;


    //MARK:并发症选择手势
    UITapGestureRecognizer *syndromeViewTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(syndromeTap:)];
    
    [syndromeView addGestureRecognizer:syndromeViewTap];
    [self.view addSubview:syndromeView];
    
    [syndromeView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(selectDisease.mas_bottom).offset(10);
//        make.left.equalTo(self.view).offset(15);
//        make.right.equalTo(self.view).offset(-15);
        make.left.right.equalTo(selectDisease);
        make.height.mas_equalTo(40);
        
    }];
    
    UILabel *syndromeLab = [UILabel cz_labelWithText:@"请选择并发症(多选):" fontSize:18 color:[UIColor cz_colorWithHex:0x40E0D0]];
    
    [syndromeView addSubview:syndromeLab];
    
    [syndromeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(syndromeView).offset(5);
        make.centerY.equalTo(syndromeView);
        
    }];


    //MARK:是否确诊视图
    UIView *confirmedView = [[UIView alloc]init];
    confirmedView.backgroundColor = [UIColor whiteColor];
    
    confirmedView.layer.cornerRadius = 10;
    confirmedView.layer.masksToBounds = YES;
    
    [self.view addSubview:confirmedView];
    
    [confirmedView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(syndromeView.mas_bottom).offset(10);
        //        make.left.equalTo(self.view).offset(15);
        //        make.right.equalTo(self.view).offset(-15);
        make.left.right.equalTo(selectDisease);
        make.height.mas_equalTo(40);
        
    }];
    
    UILabel *confirmedLab = [UILabel cz_labelWithText:@"是否确诊:" fontSize:18 color:[UIColor cz_colorWithHex:0x40E0D0]];
    
    [confirmedView addSubview:confirmedLab];
    
    [confirmedLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(confirmedView).offset(5);
        make.centerY.equalTo(confirmedView);
        
    }];
    
    //按钮
    UIButton *tureBtn = [[UIButton alloc]init];
    
    [tureBtn setImage:[UIImage imageNamed:@"illness_rb_img_nor.png"] forState:UIControlStateNormal];
    [tureBtn setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateSelected];
    
    //MARK: 是否确诊 - 确诊按钮添加事件
    [tureBtn addTarget:self action:@selector(tureBtnChilk:) forControlEvents:UIControlEventTouchDragInside];
    
    //和照片一样大;
    [tureBtn sizeToFit];
    
    [confirmedView addSubview:tureBtn];
    
    [tureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(confirmedView);
        make.left.equalTo(confirmedView).offset(220);
        
    }];
    
    UILabel *tureLabel = [UILabel cz_labelWithText:@"确诊" fontSize:18 color:[UIColor cz_colorWithHex:0x6d6d6d]];
    [confirmedView addSubview:tureLabel];
    
    [tureLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(tureBtn.mas_right).offset(5);
        make.centerY.equalTo(tureBtn);
        
    }];
    
    UIButton *suspectedBtn = [[UIButton alloc]init];
    
    [suspectedBtn setImage:[UIImage imageNamed:@"illness_rb_img_nor.png"] forState:UIControlStateNormal];
    [suspectedBtn setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateHighlighted];
    
    //MARK: 是否确诊 - 疑似按钮添加事件
//    [btn2 addTarget:self action:@selector(btn2Chilk:) forControlEvents:UIControlEventTouchDragInside];
    
    //和照片一样大;
    [suspectedBtn sizeToFit];
    
    [confirmedView addSubview:suspectedBtn];
    
    [suspectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(confirmedView);
        make.left.equalTo(tureLabel.mas_right).offset(10);
        
    }];
    
    
    UILabel *suspectedLabel = [UILabel cz_labelWithText:@"疑似" fontSize:18 color:[UIColor cz_colorWithHex:0x6d6d6d]];
    [confirmedView addSubview:suspectedLabel];
    
    [suspectedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(suspectedBtn.mas_right).offset(5);
        make.centerY.equalTo(suspectedBtn);
        
    }];
    
    
    
    //MARK:是否有医疗史视图
    UIView *isMedicalView = [[UIView alloc]init];
    isMedicalView.backgroundColor = [UIColor whiteColor];
    
    isMedicalView.layer.cornerRadius = 10;
    isMedicalView.layer.masksToBounds = YES;
    
    [self.view addSubview:isMedicalView];
    
    [isMedicalView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(confirmedView.mas_bottom).offset(10);
        //        make.left.equalTo(self.view).offset(15);
        //        make.right.equalTo(self.view).offset(-15);
        make.left.right.equalTo(selectDisease);
        make.height.mas_equalTo(40);
        
    }];
    
    UILabel *isMedicalLab = [UILabel cz_labelWithText:@"是否有医疗史:" fontSize:18 color:[UIColor cz_colorWithHex:0x40E0D0]];
    
    [isMedicalView addSubview:isMedicalLab];
    
    [isMedicalLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(isMedicalView).offset(5);
        make.centerY.equalTo(isMedicalView);
        
    }];
    
    //按钮
    UIButton *yesBtn = [[UIButton alloc]init];
    
    [yesBtn setImage:[UIImage imageNamed:@"illness_rb_img_nor.png"] forState:UIControlStateNormal];
    [yesBtn setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateHighlighted];
    
    //MARK: 是否有医疗史 - 存在按钮添加事件
    [yesBtn addTarget:self action:@selector(yesBtn:) forControlEvents:UIControlEventTouchDragInside];
    
    //和照片一样大;
    [yesBtn sizeToFit];
    
    [isMedicalView addSubview:yesBtn];
    
    [yesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(isMedicalView);
        make.left.equalTo(isMedicalView).offset(220);
        
    }];
    
    UILabel *yesLabel = [UILabel cz_labelWithText:@"存在" fontSize:18 color:[UIColor cz_colorWithHex:0x6d6d6d]];
    [isMedicalView addSubview:yesLabel];
    
    [yesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(yesBtn.mas_right).offset(5);
        make.centerY.equalTo(yesBtn);
        
    }];
    
    UIButton *noBtn = [[UIButton alloc]init];
    
    [noBtn setImage:[UIImage imageNamed:@"illness_rb_img_nor.png"] forState:UIControlStateNormal];
    [noBtn setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateHighlighted];
    
    //MARK: 是否有医疗史 - 没有按钮添加事件
    [noBtn addTarget:self action:@selector(noBtn:) forControlEvents:UIControlEventTouchDragInside];
    
    //和照片一样大;
    [noBtn sizeToFit];
    
    [isMedicalView addSubview:noBtn];
    
    [noBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(isMedicalView);
        make.left.equalTo(yesLabel.mas_right).offset(10);
        
    }];
    
    
    UILabel *noLabel = [UILabel cz_labelWithText:@"没有" fontSize:18 color:[UIColor cz_colorWithHex:0x6d6d6d]];
    [isMedicalView addSubview:noLabel];
    
    [noLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(noBtn.mas_right).offset(5);
        make.centerY.equalTo(noBtn);
        
    }];

    
    //MARK:曾经治疗方式视图
    UIView *isTreatmentView = [[UIView alloc]init];
    isTreatmentView.backgroundColor = [UIColor whiteColor];
    
    isTreatmentView.hidden = YES;
    
    isTreatmentView.layer.cornerRadius = 10;
    isTreatmentView.layer.masksToBounds = YES;
    
    //MARK: 病历史手势添加
    UITapGestureRecognizer *isTreatmentTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(istreatmentTap:)];
    [isTreatmentView addGestureRecognizer:isTreatmentTap];
    
    [self.view addSubview:isTreatmentView];
    
    [isTreatmentView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(isMedicalView.mas_bottom).offset(10);
        //        make.left.equalTo(self.view).offset(15);
        //        make.right.equalTo(self.view).offset(-15);
        make.left.right.equalTo(selectDisease);
        make.height.mas_equalTo(40);

    }];
    
    UILabel *isTreatmentLab = [UILabel cz_labelWithText:@"曾经的治疗方式:" fontSize:18 color:[UIColor cz_colorWithHex:0x40E0D0]];
    
    [isTreatmentView addSubview:isTreatmentLab];
    
    [isTreatmentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(isTreatmentView).offset(5);
        make.centerY.equalTo(isTreatmentView);
        
    }];
    
    
    //MARK: 属性记录
    _doctorCount = doctorCountV;
    _bottonView = bottonView;
    //确诊按钮
    _tureButton = tureBtn;
    //曾经治疗
    _isTreatmentView = isTreatmentView;
    //推荐医生数量
    _doctorCountView = doctorCountV;
    
    _label = lab;
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    
}



@end
